home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 1999 June / maximum-cd-1999-06.iso / Fireworks 2 / data1.cab / Program_Files / Settings / HTML_Code / Dreamweaver_Library.lbi / Imagemap.htt next >
Encoding:
Text File  |  1999-03-01  |  6.8 KB  |  232 lines

  1. // Fireworks Dreamweaver 2.0 Library imagemap output.
  2. // Version 2.0 24JAN99
  3.  
  4.  
  5. // To export HTML without comments change the value of variable doComments to "false".
  6. var doComments=true;
  7.  
  8. // When doComments is set to "true" the WRITE_HTML_COMMENT and WRITE_JS_COMMENT functions
  9. // include HTML and JavaScript in the exported file.
  10. function WRITE_HTML_COMMENT(str) {
  11.     if (doComments) WRITE_HTML("<!--"+str+"-->\n");
  12. }
  13.  
  14. function WRITE_JS_COMMENT(str) {
  15.     if (doComments) WRITE_HTML("/* "+str+" */\n");
  16. }
  17.  
  18. WRITE_HTML("\n")
  19.  
  20. WRITE_HTML("\n");
  21.  
  22. // Write HTML target and date created.
  23. var d = new Date();
  24. WRITE_HTML("<!-- Fireworks 2.0  Dreamweaver 2.0 Library target.  \n    Created ", d, " -->\n");
  25. WRITE_HTML("\n")
  26.  
  27. // Declare variables for processing Behaviors.
  28. var hasImagemap = false;
  29. var hasStatusMessages = false;
  30.  
  31. var kActionStatusMessage = 1;
  32. var kActionSwapImage = 2;
  33. var kActionRadioGroup = 3;
  34.  
  35. var kEventMouseOver = 0;
  36. var kEventOnClick = 1;
  37. var kEventMouseOut = 2;
  38.  
  39. // Write a client-side imagemap
  40. if (exportDoc.clientMap) { 
  41.     var i = 0;
  42.     while (i < imagemap.numberOfURLs) {
  43.         hasImagemap = true; // at least 1 url in the imagemap.
  44.         for (var j=0; j<imagemap[i].behaviors.numberOfBehaviors; j++) {
  45.             var curBehavior = imagemap[i].behaviors[j];
  46.             if (curBehavior.action == kActionStatusMessage) {
  47.                 hasStatusMessages = true;
  48.             }
  49.         }
  50.         i++;
  51.     }
  52.     if (exportDoc.hasBackgroundLink) {
  53.         hasImagemap = true;
  54.     }
  55. }
  56.  
  57. /* Note: In simple imagemaps using the template Imagemap.htt, the only available 
  58.    behavior is the status bar message. Otherwise, the Slices.htt template is used. */
  59. function ProcessBehavior(theCurBehaviors) {
  60.     var gotJavascript = false;
  61.     var overStat = false;
  62.     var hitStat = false;
  63.     var outStat = false;
  64.     var eraseStatOnRestore = false;
  65.     for (var i=0; i<theCurBehaviors.numberOfBehaviors; i++) {
  66.         var curBehavior = theCurBehaviors[i];
  67.         var curJavascript = "";
  68.         var gotStat = false;
  69.         if (curBehavior.action == kActionStatusMessage) {
  70.             gotJavascript = true;
  71.             gotStat = true;
  72.             var statMsg = curBehavior.statusText;
  73.             var restore = curBehavior.restoreOnMouseout;
  74.             curJavascript += "MM_displayStatusMsg('" + statMsg + "');";
  75.             if (restore) {
  76.                 eraseStatOnRestore =  true;
  77.             }
  78.         } else {
  79.             continue;
  80.         }
  81.         if (curBehavior.event == kEventMouseOver) {
  82.             javaOver += curJavascript;
  83.             if (gotStat) overStat = true;
  84.         }
  85.         if (curBehavior.event == kEventMouseOut) {
  86.             javaOut += curJavascript;
  87.             if (gotStat) outStat = true;
  88.         }
  89.         if (curBehavior.event == kEventOnClick) {
  90.             javaClick += curJavascript;
  91.             if (gotStat) hitStat = true;
  92.         }
  93.     }
  94.     if (eraseStatOnRestore) {
  95.         javaOut += "MM_displayStatusMsg(' ');" ;
  96.         outStat = true;
  97.     }
  98.     var ret = "return document.MM_returnValue";
  99.     if (overStat) javaOver += ret;
  100.     if (outStat) javaOut += ret;
  101.     if (hitStat) javaClick += ret;
  102.     return(gotJavascript);
  103. }
  104.  
  105.  
  106. // If a server-side image map is being export, write commented not on replacing file path.
  107. if (exportDoc.serverMap) {
  108.     WRITE_HTML("<!--   ----------------------------------- NOTE ----------------------------------   --->\n");
  109.     WRITE_HTML("<!--   Replace the text in the following HREF tag with the path to your map file's    -->\n");
  110.     WRITE_HTML("<!--   location on the server. The \"", exportDoc.pathBase, ".map\" file generated by Fireworks needs to be  -->\n");
  111.     WRITE_HTML("<!--   placed in a directory with a CGI Application capable of interpreting the Image -->\n");
  112.     WRITE_HTML("<!--   Map information. If you are unsure about this, contact your web site           -->\n");
  113.     WRITE_HTML("<!--   administrator.                                                                 -->\n");
  114.     WRITE_HTML("\n");
  115.     
  116.     // Generate link to image map file.    
  117.     WRITE_HTML("<a href=\"path_to_map_file/", exportDoc.pathBase, ".map\">\n");
  118. }
  119.  
  120. // Write image tag.
  121. WRITE_HTML("<img src=\"", exportDoc.filename,"\" "); 
  122.  
  123. WRITE_HTML("width=\"", exportDoc.width, "\" height=\"", exportDoc.height, "\"");
  124. if (hasImagemap) {
  125.     WRITE_HTML(" usemap=\"#", exportDoc.imagename, "\"")
  126. }
  127. if (exportDoc.serverMap) {
  128.     WRITE_HTML(" ismap");
  129. }
  130.  
  131. WRITE_HTML(" border=\"0\" >\n");
  132.  
  133. if (exportDoc.serverMap) {
  134.     WRITE_HTML("</a>\n");
  135. }
  136.  
  137. WRITE_HTML("\n");
  138.  
  139. // Write client-side image map.
  140. if (hasImagemap) {
  141.     WRITE_HTML("<map name=\"", exportDoc.imagename, "\">\n");
  142.  
  143.     var i = 0;
  144.     while (i < imagemap.numberOfURLs) {
  145.         var curImagemap = imagemap[i];
  146.         var behaviors = curImagemap.behaviors;
  147.         var javaOver = "";
  148.         var javaOut = "";
  149.         var javaClick = "";
  150.         var gotJavascript = ProcessBehavior(behaviors);
  151.  
  152.         // Write the area tag with shape definitions.
  153.         WRITE_HTML("<area shape=\"");
  154.         WRITE_HTML(curImagemap.shape); // Shapes are rect poly and circle
  155.         WRITE_HTML("\" coords=\"");
  156.         for (var j=0; j<curImagemap.numCoords; j++) {
  157.             if (j>0) WRITE_HTML(",");
  158.             // polygon has n coords.
  159.             // rect has 2 coords, topLeft, and botomRight.
  160.             // Circle has one coord, center; plus radius.
  161.             WRITE_HTML(curImagemap.xCoord(j), ",", curImagemap.yCoord(j)); 
  162.         }
  163.         if (curImagemap.shape == "circle") {
  164.             // Write the radius for circle hotspots.
  165.             WRITE_HTML(", ", curImagemap.radius);
  166.         }
  167.         WRITE_HTML("\"");
  168.         var href = " href=\"#\"";
  169.         if (curImagemap.hasHref) {
  170.             href = " href=\"";
  171.             href += curImagemap.href;
  172.             href += "\"";
  173.             if (curImagemap.hasTargetText) {
  174.                 href += " target=\"";
  175.                 href += curImagemap.targetText;
  176.                 href += "\"";
  177.             }
  178.         }
  179.  
  180.         // Write status bar message behaviors.
  181.         if (javaOut != "") {
  182.             WRITE_HTML(" onMouseOut=\"", javaOut, "\" ");
  183.         }
  184.         if (javaOver != "") {
  185.             WRITE_HTML(" onMouseOver=\"", javaOver, "\" ");
  186.         }
  187.         if (javaClick != "") {
  188.             WRITE_HTML(" onClick=\"", javaClick, "\" ");
  189.         }
  190.         WRITE_HTML(href);
  191.  
  192.         // Write alt text for hotspot.
  193.         var altText = "";
  194.         if (curImagemap.hasAltText) {
  195.             altText = curImagemap.altText;
  196.         } else {
  197.             altText = exportDoc.altText;
  198.         }
  199.  
  200.         if (altText!="") {
  201.             WRITE_HTML(" title=\"", altText, "\"");
  202.             WRITE_HTML(" alt=\"", altText, "\"");
  203.         }
  204.  
  205.         WRITE_HTML(" >\n");
  206.         i++;
  207.     } 
  208.     
  209.     // Write the image's default URL here.
  210.     if (exportDoc.hasBackgroundLink && exportDoc.backgroundLink.href != "") {
  211.         var curImagemap = exportDoc.backgroundLink;
  212.         WRITE_HTML("<area shape=\"rectangle\" coords=\"0,0, ", exportDoc.width, ",", exportDoc.height, "\" ");
  213.         WRITE_HTML("href=\"", curImagemap.href, "\"");
  214.         if (curImagemap.hasTargetText) {
  215.             WRITE_HTML("\n  target=\"", curImagemap.targetText, "\"");
  216.         }
  217.         var altText = exportDoc.altText;
  218.         if (altText!="") {
  219.             WRITE_HTML(" title=\"", altText, "\"");
  220.             WRITE_HTML(" alt=\"", altText, "\"");
  221.         }
  222.         WRITE_HTML(">\n");
  223.     }    
  224.  
  225.     WRITE_HTML("</map>\n")
  226.     WRITE_HTML("\n");
  227.     
  228.     WRITE_HTML_COMMENT("   Image Map created with Macromedia Fireworks 2.0   ")
  229. }
  230.  
  231. WRITE_HTML("\n")
  232.